/* Copyright (c) 2010 OFXKit
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#import <Foundation/Foundation.h>
#import "OFXDocument.h"
#import "OFXAccountInfo.h"

@interface OFXDocumentResponse : OFXDocument {
  OFXAccountInfo* accountInfo;
  OFXSignOn* signOnResponse;
  NSMutableArray* securitiesList;  
  NSMutableArray* statements;
}

/**
 * @property accountInfo
 * @brief List of accounts from an OFX account information request.
 */
@property(retain) OFXAccountInfo* accountInfo;

/**
 * @property signOnResponse
 * @brief Server response to the sign on request.
 */
@property(retain) OFXSignOn* signOnResponse;

/**
 * @property statements
 * @brief Array of OFXStatements returned by the server.
 */
@property(retain) NSMutableArray* statements;

/**
 * @property securitiesList
 * @brief Array of security information returned by the server.
 */
@property(retain) NSMutableArray* securitiesList;

/**
 * Initialize the document response.
 */
- (id) init;

/**
 * Create an OFX document with the contents of the file specified by path.
 *
 * @param path Path to a file in the filesystem to load into the OFX document.
 * @param enc Encoding of the document to load.
 * @param error Pointer to an error object if an error occurs.
 * 
 * @returns A new OFXDocumentResponse initialized with the contents of the file
 * specified by path.
 */
+ (id) ofxDocumentWithContentsOfFile:(NSString*)path
                            encoding:(NSStringEncoding)enc 
                               error:(NSError**)error;

/**
 * Create an OFX document with the contents of the file specified by url.
 *
 * @param url URI of file to load into OFXDocumentResponse
 * @param enc Encoding of the document to load.
 * @param error Pointer to an error object if an error occurs.
 * 
 * @returns A new OFXDocumentResponse initialized with the contents of the URI
 * specified by url.
 */
+ (id) ofxDocumentWithContentsOfURL:(NSURL*)url 
                           encoding:(NSStringEncoding)enc 
                              error:(NSError**)error;

/**
 * Create an OFX document with the contents of the string ofxData.
 *
 * @param ofxData String containing OFX data to initialize document with.
 * @param enc Encoding of the document to load.
 * @param error Pointer to an error object if an error occurs.
 * 
 * @returns A new OFXDocumentResponse initialized with the contents of the 
 * string ofxData.
 */
+ (id) ofxDocumentWithContentsOfString:(NSString*)ofxData 
                              encoding:(NSStringEncoding)enc 
                                 error:(NSError**)error;

/**
 * Internal method used to convert an SGML string to XML.
 *
 * @param sgmlString A string containing SGML data to be converted into XML.
 *
 * @returns A string where closing tags have been inserted where appropriate.
 */
+ (NSString *) convertSgmlToXmlWithString:(NSString *)sgmlString;

@end
